#include "stdafx.h"
#include "wf_modifyattributes.h"

#include "pf_modification.h"
#include "pf_snapper.h"



WF_ModifyAttributes::WF_ModifyAttributes(
    PF_Container& container,
    PF_GraphicView& graphicView)
        :PF_ActionInterface("Change Attributes",
                    container, graphicView) {}


QAction* WF_ModifyAttributes::createGUIAction(LX_Define::ActionType /*type*/, QObject* /*parent*/) {
	// tr("Attributes")
    QAction* action = new QAction(tr("&Attributes"),  NULL);
	action->setIcon(QIcon(":/extui/modifyattributes.png"));
    //action->zetStatusTip(tr("Modify Entity Attributes"));
    return action;
}


void WF_ModifyAttributes::init(int status) {
    PF_ActionInterface::init(status);

    trigger();
}



void WF_ModifyAttributes::trigger() {

    PF_DEBUG->print("PF_ActionModifyAttributes::trigger()");

    PF_AttributesData data;
    data.pen = PF_Pen();
    data.layer = "0";
    data.changeColor = false;
    data.changeLineType = false;
    data.changeWidth = false;
    data.changeLayer = false;

    if (graphic!=NULL) {
        if (PF_DIALOGFACTORY->requestAttributesDialog(data,
                *graphic->getLayerList())) {
            PF_Modification m(*container, graphicView);
            m.changeAttributes(data);
        }
    }

    finish();
    graphicView->killSelectActions();

    PF_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
}



void WF_ModifyAttributes::updateMouseButtonHints() {
    switch (getStatus()) {
        //case Acknowledge:
        //PF_DIALOGFACTORY->updateMouseWidget(tr("Acknowledge"), tr("Cancel"));
        //break;
    default:
        PF_DIALOGFACTORY->updateMouseWidget("", "");
        break;
    }
}



void WF_ModifyAttributes::updateMouseCursor() {
    graphicView->setMouseCursor(LX_Define::DelCursor);
}



void WF_ModifyAttributes::updateToolBar() {
    if (!isFinished()) {
        PF_DIALOGFACTORY->requestToolBar(LX_Define::ToolBarModify);
    } else {
        PF_DIALOGFACTORY->requestToolBar(LX_Define::ToolBarMain);
    }
}


// EOF
